/// @tags: Tarjan
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

namespace BlueQuantum {

typedef unsigned long long ULL;

constexpr int MAXN = 1e6 + 3;

int dcnt, rtson;
int dfn[MAXN], low[MAXN], ccnt[MAXN], vis[MAXN];
bool cut[MAXN];
vector<int> G[MAXN];

void tarjan(int u, int fa) {
  dfn[u] = low[u] = ++dcnt;
  for (auto v : G[u]) {
    if (dfn[v] == 0) {
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        if (u != 1)
          cut[u] = true;
        else
          rtson++;
      }
    } else {
      low[u] = min(low[u], dfn[v]);
    }
  }
}

int dfs(int u, int id) {
  vis[u] = id;
  int res = 1;
  for (auto v : G[u]) {
    if (cut[v] && vis[v] != id)
      ccnt[id]++, vis[v] = id;
    else if (vis[v] == 0)
      res += dfs(v, id);
  }
  return res;
}

inline int main() {
  int Case = 0;
  while (true) {
    int n = 0, m;
    cin >> m;
    if (m == 0) break;
    for (int i = 1, u, v; i <= m; ++i) {
      cin >> u >> v;
      n = max(n, max(u, v));
      G[u].push_back(v);
      G[v].push_back(u);
    }
    tarjan(1, 1);
    if (rtson >= 2) cut[1] = true;
    int gcnt = 0, ecnt = 0;
    ULL pcnt = 1;
    for (int i = 1; i <= n; ++i) {
      if (vis[i] == false && cut[i] == false) {
        int siz = dfs(i, ++gcnt);
        if (ccnt[gcnt] == 0) {
          ecnt += 2;
          pcnt *= (siz - 1) * siz / 2;
        }
        if (ccnt[gcnt] == 1) {
          ecnt += 1;
          pcnt *= siz;
        }
      }
    }
    for (int i = 1; i <= n; ++i) G[i].clear();
    memset(cut, 0, sizeof(cut));
    memset(ccnt, 0, sizeof(ccnt));
    memset(dfn, 0, sizeof(dfn));
    memset(vis, 0, sizeof(vis));
    memset(low, 0, sizeof(low));
    dcnt = 0;
    rtson = 0;
    cout << "Case " << ++Case << ": " << ecnt << ' ' << pcnt << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3225 [HNOI2012] 矿场搭建.in", "r", stdin);
  freopen("P3225 [HNOI2012] 矿场搭建.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
